package com.qinggeng.framework.config.mq.impl;

import com.alibaba.fastjson.JSONObject;
import com.qinggeng.framework.config.mq.dto.MessageShareWithdrawalDTO;
import com.qinggeng.framework.config.mq.handle.MessageHandle;
import com.qinggeng.project.system.service.IUserAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ShareWithdrawalHandleImpl implements MessageHandle {
    @Autowired
    private IUserAccountService userAccountService;

    @Override
    public void handle(String msg) {
        MessageShareWithdrawalDTO messageShareWithdrawalDTO = JSONObject.parseObject(msg, MessageShareWithdrawalDTO.class);
        Long userId = messageShareWithdrawalDTO.getUserId();
        Long messageId = messageShareWithdrawalDTO.getMessageId();
        Integer type = messageShareWithdrawalDTO.getType();
        String money = messageShareWithdrawalDTO.getMoney();
        userAccountService.shareWithdrawal(userId,messageId,type,money);
    }
}
